#include<iostream>
#include<vector>
using namespace std;

class Gloves {
public:
    int findMinimum(int n, vector<int> left, vector<int> right) {
        int zero = 0, suml = 0, sumr = 0, minl = INT_MAX, minr = INT_MAX;
        for (int i = 0; i < n; ++i)
        {
            if (left[i] * right[i] == 0)
                zero += left[i] + right[i];
            else
            {
                suml += left[i];
                minl = min(minl, left[i]);

                sumr += right[i];
                minr = min(minr, right[i]);
            }
        }
        return zero + min(suml - minl + 1, sumr - minr + 1) + 1;
    }
};
int main()
{
    vector<int> v1 = { 0,7,1,6 };
    vector<int> v2 = { 1,5,0,6 };
    cout<<Gloves().findMinimum(4, v1, v2);
    return 0;
}